//
//  ChartCategoryDetailWeekView.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 08.04.25.
//

import SwiftUI

struct ChartCategoryDetailDateWeekView: View {
    
    @StateObject var viewModel: ChartCategoryDetailDateViewModel
    
    init(date: Date, category: AccountingCategory) {
        _viewModel = StateObject(wrappedValue: ChartCategoryDetailDateViewModel(date: date, category: category))
    }
    
    var body: some View {
        ChartCategoryDetailDateBaseView(
            date: $viewModel.date,
            dateType: .week,
            totalAmount: $viewModel.totalAmount,
            averageAmount: $viewModel.averageAmount,
            trendData: $viewModel.trendData,
            categoryDetailList: $viewModel.categoryDetailList,
            category: $viewModel.category,
            orderBy: $viewModel.orderBy,
            loadData: {
                loadData()
            })
    }
    
    private func loadData() {
        viewModel.loadData(dateType: .week)
    }
}

#Preview {
    ChartCategoryDetailDateWeekView(date: Date(), category: AccountingCategory())
}
